package com.mdata.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
public class ResultData {

    private Integer code;

    private String msg;

    private Object data;

    public static ResultData success() {
        return new ResultData(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), null);
    }

    public static ResultData success(Object data) {
        return new ResultData(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), data);
    }

    public static ResultData success(Object data, String msg) {
        return new ResultData(ResponseEnum.SUCCESS.getCode(), msg, data);
    }

    public static ResultData error(ResponseEnum errorEnum) {
        return new ResultData(errorEnum.getCode(), errorEnum.getMsg(), null);
    }

    public static ResultData error(Integer code, String msg) {
        return new ResultData(code, msg, null);
    }

    public static ResultData error(Integer code, String msg, Object data) {
        return new ResultData(code, msg, data);
    }
}
